<html>
<head><meta charset="utf-8"><title>Issue #6064 · clippy · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/index.html">clippy</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20.236064.html">Issue #6064</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="224647188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20%236064/near/224647188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshitomo Nakanishi <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20.236064.html#224647188">(Jan 31 2021 at 14:27)</a>:</h4>
<p>Hi! I started working on <a href="https://github.com/rust-lang/rust-clippy/issues/6064">https://github.com/rust-lang/rust-clippy/issues/6064</a> and stuck on it.<br>
I read <code>rustc_typeck</code> to know how default numeric fallback is handled and found there is no way to know whether default numeric fallback occurs from outside. This means we can't know whether an Eq constraint between unsuffixed numeric type and i32 or f64 is inserted by default numeric fallback or by something else.<br>
So, it seems that we have to implement another pass to resolve an unsuffixed numeric value to see it's possible without default numeric fallback.  Is this right?</p>



<a name="224648371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20%236064/near/224648371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20.236064.html#224648371">(Jan 31 2021 at 14:56)</a>:</h4>
<p>When classifying the lint as restriction, you shouldn't worry about if the type was inferred or if a fallback occurs. I even think that the compiler doesn't differentiate here. If no type is specified and can't infer anything else, than the default type is inferred. So in every case a type is inferred.</p>
<p>Just lint assignments with type <code>i32</code>/<code>f32</code>  if the type wasn't specified.</p>



<a name="224649016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20%236064/near/224649016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshitomo Nakanishi <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20.236064.html#224649016">(Jan 31 2021 at 15:10)</a>:</h4>
<p>In that case, we can't lint below code.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">t</span>: <span class="nc">T</span><span class="p">)</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">T</span>: <span class="nc">num_traits</span>::<span class="n">int</span>::<span class="n">PrimInt</span><span class="p">,</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Is it ok?<br>
I think this lint is most useful when type inference is involved.</p>



<a name="224649302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20%236064/near/224649302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20.236064.html#224649302">(Jan 31 2021 at 15:16)</a>:</h4>
<p>I mean, you could also find a way to lint that (I don't have an idea how to best handle this case myself). But you can also leave that as an enhancement to the lint and start with the simplest case of assignments.</p>



<a name="224649697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20%236064/near/224649697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshitomo Nakanishi <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20.236064.html#224649697">(Jan 31 2021 at 15:25)</a>:</h4>
<p>Thanks for clarifying,  I completely understand what you mean! I'll start implementation from easiest case.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>